
package com.micro.school.system.convert.student;


import com.micro.school.system.domain.BatchLogDetail;
import com.micro.school.system.domain.StudentBatchLog;
import com.micro.school.system.domain.vo.BatchLogDetailVo;
import com.micro.school.system.domain.vo.StudentBatchLogVo;

import java.util.ArrayList;
import java.util.List;


public interface StudentBatchLogConvert {

    /**
     * 将 StudentBatchLogVo 转换为 StudentBatchLog 实体
     * @param vo StudentBatchLogVo 对象
     * @return StudentBatchLog 实体对象
     */
    public static StudentBatchLog convertToEntity(StudentBatchLogVo vo) {
        if (vo == null) {
            return null;
        }

        StudentBatchLog entity = new StudentBatchLog();
        entity.setBatchId(vo.getBatchId());
        entity.setBatchTime(vo.getBatchTime());
        entity.setStatus(vo.getStatus());
        entity.setType(vo.getType());
        entity.setCreateAt(vo.getCreateAt());
        entity.setApproval(vo.getApproval());
        entity.setTenantId(vo.getTenantId());
        entity.setNewsImport(vo.getNewsImport());
        // 注意：remark 字段在 Vo 中不存在，所以无法从 Vo 设置
        return entity;
    }

    /**
     * 将 StudentBatchLog 实体转换为 StudentBatchLogVo
     * @param entity StudentBatchLog 实体对象
     * @return StudentBatchLogVo 对象
     */
    public static StudentBatchLogVo convertToVo(StudentBatchLog entity) {
        if (entity == null) {
            return null;
        }

        StudentBatchLogVo vo = new StudentBatchLogVo();
        vo.setBatchId(entity.getBatchId());
        vo.setBatchTime(entity.getBatchTime());
        vo.setStatus(entity.getStatus());
        vo.setType(entity.getType());
        vo.setCreateAt(entity.getCreateAt());
        vo.setApproval(entity.getApproval());
        vo.setTenantId(entity.getTenantId());
        vo.setNewsImport(entity.getNewsImport());
        // startDate 和 endDate 是 Vo 特有的字段，实体中没有对应字段
        return vo;
    }

    /**
     * 将 StudentBatchLog 实体列表转换为 StudentBatchLogVo 列表
     * @param entities StudentBatchLog 实体列表
     * @return StudentBatchLogVo 列表
     */
    public static List<StudentBatchLogVo> convertToVoList(List<StudentBatchLog> entities) {
        if (entities == null) {
            return null;
        }

        List<StudentBatchLogVo> vos = new ArrayList<>();
        for (StudentBatchLog entity : entities) {
            StudentBatchLogVo vo = convertToVo(entity);
            if (vo != null) {
                vos.add(vo);
            }
        }
        return vos;
    }

    /**
     * 将 StudentBatchLogVo 列表转换为 StudentBatchLog 实体列表
     * @param vos StudentBatchLogVo 列表
     * @return StudentBatchLog 实体列表
     */
    public static List<StudentBatchLog> convertToEntityList(List<StudentBatchLogVo> vos) {
        if (vos == null) {
            return null;
        }

        List<StudentBatchLog> entities = new ArrayList<>();
        for (StudentBatchLogVo vo : vos) {
            StudentBatchLog entity = convertToEntity(vo);
            if (entity != null) {
                entities.add(entity);
            }
        }
        return entities;
    }

    /**
     * 批量设置额外字段（如 startDate 和 endDate）
     * @param vo StudentBatchLogVo 对象
     * @param startDate 开始日期
     * @param endDate 结束日期
     */
    public static void setAdditionalFields(StudentBatchLogVo vo, String startDate, String endDate) {
        if (vo != null) {
            vo.setStartDate(startDate);
            vo.setEndDate(endDate);
        }
    }
}
